// prevents highlighting i.e. text selection on double click
.no-highlight {
    -webkit-user-select: none; /* webkit (safari, chrome) browsers */
    -moz-user-select: none; /* mozilla browsers */
    -khtml-user-select: none; /* webkit (konqueror) browsers */
    -ms-user-select: none; /* IE10+ */
}

// prevents transitions i.e. when reseting a progress bar
.no-transition {
    -webkit-transition: none !important;
    -moz-transition: none !important;
    -o-transition: none !important;
    -ms-transition: none !important;
    transition: none !important;
}

// rotates an element i.e. used for font-awesome icons
.fa-rotate-45 {
    -webkit-transform: rotate(45deg);
    -moz-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    -o-transform: rotate(45deg);
    transform: rotate(45deg);
}

// utility class from: https://github.com/twbs/bootstrap/pull/27268
.overflow-auto {
    overflow: auto !important;
}

// default margins
$ui-margin-vertical: $margin-v * 0.25;
$ui-margin-vertical-large: $margin-v * 0.5;
$ui-margin-horizontal: $margin-h;
$ui-margin-horizontal-small: $margin-h * 0.5;
$ui-margin-horizontal-large: $margin-v * 2;

.ui-modal {
    display: none;
    overflow: auto;
    .modal-header.no-separator {
        border: none !important;
        padding-bottom: 0px !important;
    }
    .modal-backdrop {
        z-index: -1;
        opacity: 0.5;
    }
    .modal-body {
        position: static;
    }
    .modal-footer {
        .buttons {
            float: right;
        }
    }
}

// buttons
.ui-button-default {
    float: right;
    .progress {
        .progress-bar {
            @extend .no-transition;
            background: darken($state-success-bg, 30%);
        }
    }
}

.ui-button-icon-plain {
    @extend .icon-btn;
    @extend .p-0;
    border: none !important;
    background: none !important;
    float: right;
}

.ui-button-check {
    .icon {
        font-size: 1.2em;
        width: 1em;
    }
    cursor: pointer;
}

// tabs
.tabbable {
    .nav-item {
        cursor: pointer;
    }
}

// thumbnails
.ui-thumbnails {
    .ui-thumbnails-item {
        cursor: pointer;
        .ui-thumbnails-image {
            padding: 10px;
            width: 100px;
            height: 86px;
        }
        .ui-thumbnails-icon {
            width: 100px;
            height: 86px;
            font-size: 4em;
            padding: 20px 26px;
            color: lighten($brand-primary, 10%);
        }
        .ui-thumbnails-text {
            word-wrap: break-word;
        }
    }
    .ui-thumbnails-item:hover {
        .ui-thumbnails-title {
            text-decoration: underline;
        }
        .ui-thumbnails-text {
            text-decoration: underline;
        }
    }
}

// table form elements
.ui-form-element {
    margin-top: $ui-margin-vertical;
    margin-bottom: $ui-margin-vertical;
    overflow: visible;
    clear: both;
    .ui-form-title {
        word-wrap: break-word;
        font-weight: bold;
        .ui-form-collapsible {
            .icon {
                cursor: pointer;
                font-size: 1.2em;
                position: relative;
                top: 1px;
            }
        }
    }
    .ui-form-field {
        position: relative;
        margin-top: $ui-margin-vertical;
        .ui-form-wp-source {
            border-left-width: 10px;
        }
        .ui-form-wp-target {
            box-shadow: none;
            border-top: none;
            border-bottom: none;
            border-right: none;
            border-left-width: 5px;
            font-style: italic;
        }
        .ui-form-backdrop {
            display: none;
            z-index: 10;
            position: absolute;
            top: 0px;
            width: 100%;
            height: 100%;
            background: $white;
            display: block;
            opacity: 0;
            cursor: default;
        }
    }
    .ui-form-preview {
        @extend .ui-input;
        margin-top: $ui-margin-vertical;
        border-color: transparent !important;
        box-shadow: none !important;
        height: auto !important;
    }
}

.ui-form-element-disabled {
    @extend .ui-form-element;
    .ui-form-title {
        font-weight: normal;
    }
}

.ui-form-composite {
    height: 100%;
    flex-direction: column;
    display: flex;
    .ui-steps {
        overflow: auto;
    }
}

// portlets
.ui-portlet {
    @extend .card;
    border: none;
    .portlet-header:first-child {
        @extend .card-header;
        @extend .rounded;
        background: $portlet-bg-color;
        .portlet-title {
            .portlet-title-text.collapsible {
                cursor: pointer;
                text-decoration: underline;
            }
        }
        .portlet-operations {
            button {
                @extend .ml-1;
            }
        }
    }
    .portlet-buttons {
        button {
            @extend .float-left;
            @extend .mr-1;
        }
    }
    > .portlet-content {
        @extend .card-body;
        @extend .p-0;
    }
    .portlet-backdrop {
        display: none;
        z-index: 10;
        position: absolute;
        top: 0px;
        width: 100%;
        height: 100%;
        opacity: 0.2;
        background: $white;
        cursor: not-allowed;
    }
}

.ui-portlet-section {
    @extend .ui-portlet;
    @extend .mb-2;
    border: none;
    border-left: solid 3px $portlet-bg-color;
    border-radius: $border-radius-large;
    .portlet-header:first-child {
        background: $portlet-bg-color;
        @extend .rounded-0;
        border-top-right-radius: $border-radius-large !important;
        padding: 5px;
    }
    > .portlet-content {
        @extend .pl-2;
        @extend .pr-0;
    }
}

// popovers
.popover {
    max-width: 700px;
    .popover-header {
        i {
            @extend .float-right;
            @extend .pl-4;
            font-size: 1.1em;
            cursor: pointer;
        }
    }
}

// input elements
.ui-input {
    @extend .form-control;
    @extend .pt-1;
    @extend .pl-2;
    height: $input-height;
    background: transparent;
    &[disabled],
    &[readonly],
    fieldset[disabled] & {
        cursor: not-allowed;
        background-color: $brand-light;
    }
}

.ui-textarea {
    @extend .ui-input;
    height: 100px !important;
}

.ui-options {
    .ui-options-list {
        @extend .ui-input;
        height: 100% !important;
        input[type="checkbox"],
        input[type="radio"] {
            display: none;
        }
        label {
            margin: 0px;
            cursor: pointer;
        }
        .ui-drilldown-button {
            float: left;
            cursor: pointer;
            font-size: 1.2em;
            margin-right: 5px;
            margin-top: 3px;
        }
        .ui-drilldown-subgroup {
            display: none;
            margin-left: 25px;
        }
        input[type="checkbox"] + label:before {
            font-family: FontAwesome;
            display: inline-block;
            font-style: normal;
            font-size: 1.2em;
            margin-right: 5px;
            position: relative;
            top: 1px;
            width: 10px;
            content: "\f096";
        }
        input[type="checkbox"]:checked + label:before {
            content: "\f046";
        }
        input[type="radio"] + label:before {
            font-family: FontAwesome;
            display: inline-block;
            font-style: normal;
            font-size: 1.2em;
            margin-right: 5px;
            position: relative;
            top: 1px;
            width: 10px;
            content: "\f1db";
        }
        input[type="radio"]:checked + label:before {
            content: "\f192";
        }
    }
}

.ui-color-picker {
    .ui-color-picker-header {
        cursor: pointer;
    }
    .ui-color-picker-value {
        float: left;
        border-radius: 3px;
        border: solid 1px #000000;
        width: 12px;
        height: 12px;
        margin-right: 5px;
    }
    .ui-color-picker-label {
        line-height: 1.2em;
        margin-bottom: 5px;
    }
    .ui-color-picker-view {
        height: 100%;
        overflow: auto;
        display: none;
        float: left;
        margin-bottom: 5px;
        .ui-color-picker-panel {
            width: 210px;
            .ui-color-picker-content {
                margin-bottom: 15px;
                .badge {
                    padding-bottom: 2px;
                }
                .line {
                    .ui-color-picker-box {
                        cursor: pointer;
                        float: left;
                        margin-right: 5px;
                        border: solid 1px #c0c0c0;
                        width: 15px;
                        height: 15px;
                        border-radius: 2px;
                        .ui-color-picker-check {
                            color: black;
                            font-size: 1.2em;
                            position: relative;
                            left: 1px;
                        }
                    }
                }
            }
            .ui-color-picker-content:first-child {
                padding-top: 5px;
                padding-bottom: 10px;
            }
            .ui-color-picker-content:last-child {
                padding-top: 85px;
                padding-bottom: 5px;
            }
        }
    }
}

.ui-select {
    position: relative;
    .icon-dropdown {
        position: absolute;
        top: 0.7rem;
        right: 0.5rem;
        cursor: pointer;
    }
    select {
        @extend .ui-input;
        cursor: pointer;
        -webkit-appearance: none;
        -moz-border-radius: $border-radius-base;
    }
    .select2-container {
        width: 100%;
        .select2-choice {
            @extend .ui-input;
            background-image: none;
            background: transparent;
            -webkit-appearance: none;
            -moz-border-radius: $border-radius-base;
            line-height: 1.5rem;
            .select2-chosen {
                white-space: normal;
            }
            .select2-arrow {
                display: none;
            }
        }
    }
    .select2-container-multi {
        .select2-choices {
            @extend .ui-input;
        }
    }
}

.ui-select-multiple {
    .icon-resize {
        position: absolute;
        right: 0rem;
        cursor: row-resize;
        i {
            position: absolute;
            right: 0.2rem;
            bottom: 0.2rem;
        }
    }
    select {
        min-height: 8rem;
    }
}

.ui-select-content {
    .btn-group {
        @extend .d-flex;
    }
}

.ui-dragover {
    border-radius: 3px;
    border: 2px solid $table-border-color;
    background: lighten($table-border-color, 30%);
    padding: 2px;
}

.ui-dragover-danger {
    @extend .ui-dragover;
    border: 2px solid $state-danger-bg;
    background: lighten($state-danger-bg, 10%) !important;
}

.ui-dragover-success {
    @extend .ui-dragover;
    border: 2px solid $state-success-bg;
    background: lighten($state-success-bg, 10%) !important;
}

// select2 adjustments
.select2-drop-active,
.select2-drop-above.select2-drop-active {
    border: 1px solid $border-default-color;
    .select2-search {
        @extend .pt-1;
    }
}
